<extend name="Public:base"/>

<!--侧边导航-->
<block name="aside">
    <include file="Public:aside"/>
</block>

<block name="main">

    <form id="myform" action="{:U('Model/insert')}" method="post" class="form-horizontal">
        <div class="form-group">
            <label class="control-label col-md-2"><font color="red">*</font>模型名称</label>
            <div class="col-md-5">
                <input type="text" name="name" value="{$vo.name}" size="20" class="form-control required"  title="{:L(module_tip_title)}" />
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2"><font color="red">*</font>模型表名</label>
            <div class="col-md-5">
                <input type="text" name="tablename" value="{$vo.tablename}" size="20" class="form-control"  validate="required:true, english:true,remote: '{:U('Module/insert?isajax=1')}' ,minlength:2, maxlength:30" />
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">列表页调用字段</label>
            <div class="col-md-5">
            <input type="text" id="listfields" name="listfields"  class="form-control" size="55" value="<if condition="empty($vo['listfields'])">*<else />{$vo.listfields}</if>" /> {:L(examples)}:id,title,url,catid
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">前台搜索模型</label>
            <div class="col-md-5">{:Form::radio(array('field'=>'issearch','options'=>array('1'=>L('yes'),'0'=>L('no'))),$vo['issearch'])}</div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2">模型简介</label>
            <div class="col-md-5"><textarea id="description" name="description" rows=4"" cols="55">{$vo.description}</textarea>
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-2">新建表字段</label>
            <div class="col-md-5">
                <input type="radio" name="emptytable" value="1"/> 空表字段
                <input type="radio" name="emptytable" value="0" checked />普通文章表字段
            </div>
        </div>
        <input type="hidden" id="type" name="type" value="{$_GET[type]}"/>
        <div  class="form-actions">
            <input type="submit"  value="提交" class="btn btn-sm btn-primary" />
            <input type="reset"  value="取消" class="btn btn-sm btn-primary"/>
        </div>
    </form>

</block>


<block name="script">
    <script type="text/javascript">
        $(document).ready(function() {
            $('#myform').ajaxForm({
                success:  complete,  // post-submit callback
                dataType: 'json'
            });
        });

        function complete(data){
            if (data.status == 1) {
                layer.msg(data.info, {
                    icon: 1,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    window.location.href = "{$Think.cookie.__forward__}";
                    return true;
                });
            } else {
                layer.msg(data.info, {
                    icon: 2,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                });
            }
        }
    </script>
</block>